package com.netx.generics.io;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;

import com.netx.generics.basic.Checker;


public class BufferedReader extends java.io.BufferedReader {
	
	public BufferedReader(InputStream in) {
		super(new InputStreamReader((InputStream)Checker.checkNull(in, "in")));
	}
	
	public BufferedReader(InputStream in, int bufferSize) {
		super(new InputStreamReader(
			(InputStream)Checker.checkNull(in, "in")
		), (int)Checker.checkMinValue(bufferSize, 1, "bufferSize"));
	}

	public BufferedReader(InputStream in, Charset cs) {
		super(new InputStreamReader(
			(InputStream)Checker.checkNull(in, "in"),
			(Charset)Checker.checkNull(cs, "cs")
		));
	}

	public BufferedReader(InputStream in, Charset cs, int bufferSize) {
		super(new InputStreamReader(
			(InputStream)Checker.checkNull(in, "in"),
			(Charset)Checker.checkNull(cs, "cs")
		), (int)Checker.checkMinValue(bufferSize, 1, "bufferSize"));
	}

	public BufferedReader(InputStream in, CharsetDecoder dec) {
		super(new InputStreamReader(
			(InputStream)Checker.checkNull(in, "in"),
			(CharsetDecoder)Checker.checkNull(dec, "dec")
		));
	}

	public BufferedReader(InputStream in, CharsetDecoder dec, int bufferSize) {
		super(new InputStreamReader(
			(InputStream)Checker.checkNull(in, "in"),
			(CharsetDecoder)Checker.checkNull(dec, "dec")
		), (int)Checker.checkMinValue(bufferSize, 1, "bufferSize"));
	}

	public BufferedReader(InputStream in, String charsetName) throws UnsupportedEncodingException {
		super(new InputStreamReader(
			(InputStream)Checker.checkNull(in, "in"),
			(String)Checker.checkEmpty(charsetName, "charsetName")
		));
	}

	public BufferedReader(InputStream in, String charsetName, int bufferSize) throws UnsupportedEncodingException {
		super(new InputStreamReader(
			(InputStream)Checker.checkNull(in, "in"),
			(String)Checker.checkEmpty(charsetName, "charsetName")
		), (int)Checker.checkMinValue(bufferSize, 1, "bufferSize"));
	}
	
	public BufferedReader(Reader reader) {
		super((Reader)Checker.checkNull(reader, "reader"));
	}

	public BufferedReader(Reader reader, int bufferSize) {
		super(
			(Reader)Checker.checkNull(reader, "reader"),
			(int)Checker.checkMinValue(bufferSize, 1, "bufferSize")
		);
	}
}
